package com.maxie.command.waiter;

import com.maxie.command.order.Order;

import java.util.ArrayList;
import java.util.List;

/**
 * 服务员 —》消息的接受者
 */
public class WaiterReceiver {

    private List<Order> orderList;
    public WaiterReceiver() {
        this.orderList = new ArrayList<>();
    }

    /**
     * 管理Order
     * @param order
     */
    public void addOrder(Order order) {
        orderList.add(order);
    }

    public void printOrders() {
        System.out.println("订单列表：");
        for (Order order : orderList) {
            System.out.println(order);
        }
    }

    // action:下单
    public void invoke() {
        for (int i = 0; i < this.orderList.size(); i++) {
            orderList.get(i).execute();
        }
    }
}
